/**
 * 项目名：五位一体化工安全信息平台
 * 日期：    2019-11-23 19:51:47
 * Copyright (c) 2015- joysuch-版权所有
 */

package com.joysuch.wwyt.risk.repository;

import com.joysuch.wwyt.risk.entity.RiskShouldKnowCard;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

/**
 * RiskShouldKnowCardDao
 *
 */
public interface RiskShouldKnowCardDao extends JpaRepository<RiskShouldKnowCard, Long> {
    public Page<RiskShouldKnowCard> findAll(Specification<RiskShouldKnowCard> spec, Pageable pageable);

    public RiskShouldKnowCard save(RiskShouldKnowCard bean);

    public void delete(RiskShouldKnowCard bean);

    public RiskShouldKnowCard findFirstByRiskDistrictId(Long riskDistrictId);

    @Query(value = "select count(id) from wwyt_risk_should_know_card where RISK_DISTRICT_ID = ?1 and DELETE_FLAG = '0'", nativeQuery = true)
    int countByRiskDistrictId(Long districtId);

}
